#ifndef USART_H
#define USART_H

#define START   0X11
#define reBiggestSize 13
#define SendBiggestSize  13
//控制位
#define Reset 0x01
#define Stop  0x02

extern unsigned char JudgeReceiveBuffer[reBiggestSize*2];//接受最大内存
extern unsigned char JudgeSend[SendBiggestSize];//发送最大内存


typedef union 
{
	short d;
	unsigned char data[2];
}sendData;

//左右轮速控制速度共用体
typedef union
{
	short d;
	unsigned char data[2];
}receiveData;

//控制车体结构体
typedef struct{
	int leftSpeedSet;
	int rightSpeedSet;
	unsigned char crtlFlag;
	char left_move;//为1时方向为正
	char right_move;
}Ctrl_information;

extern Ctrl_information chassis_ctrl;

//void DATA_DISPOSE_task(void *pvParameters);
	
//串口接受中断中接收函数
void usartReceiveData(void);

//从linux接收并解析数据到参数地址中
extern int usartReceiveOneData(int *p_leftSpeedSet,int *p_rightSpeedSet,unsigned char *p_crtlFlag);   

//封装数据，调用USART1_Send_String将数据发送给linux
extern void usartSendData(short leftVel, short rightVel,short angle,unsigned char ctrlFlag); 

//发送指定字符数组的函数
void USART_Send_String(unsigned char *p,unsigned short sendSize); 

//计算八位循环冗余校验，得到校验值，一定程度上验证数据的正确性
unsigned char getCrc8(unsigned char *ptr, unsigned short len); 

void JudgeBuffReceive(unsigned char ReceiveBuffer[]);


#endif
